#include <iostream>

using namespace std;

struct node {
	int num;
	node *next;
};

//int main() {
//	node *head, *p, *q;
//	head = new node;
//	head->next = NULL;
//	int x;
//	cin >> x;
//	p = head;
//	head->num = x;
//	while (x != -1) {
//		cin >> x;
//		q = new node;
//		p->next = q;
//		q->num = x;
//		q->next = NULL;
//		p = q;
//	}
//	p = head;
//	while (p != NULL) {
//		cout << p->num << endl;
//		p = p->next;
//	}
//	return 0;
//}



int main() {
	node *head = new node;
	node *p, *q;
	p = head;
	int x;
	cin >> x;
	while (x != -1) {

		p->num = x;
		q = new node;
		p->next = q;
		q->next = NULL;
		p = q;
		cin >> x;
	}
	p = head;
	while (p != NULL) {
		cout << p->num << endl;
		p = p->next;
	}
	return 0;
}